// pages/my/my.js
var app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    myinfo: {},
    totalRead: 0,
  },
  onLoad: function (options) {

  },

  onShow: function () {
    //获取我的用户信息
    this.getMyInfo();
    this.getTotalRead();

  },

  //获取浏览数量
  getTotalRead: function () {
    app.Ajax({
      url: '/api/index.php?app=account&act=visit_record',
      success: (res) => {
        this.setData({
          totalRead: res.total_count
        })
      }
    })
  },

  /**
     * 获取我的用户信息
     */
  getMyInfo: function () {
    app.Ajax({
      url: '/api/index.php?app=account&act=profile',
      success: (res) => {
        this.setData({
          myinfo: res
        })
      }
    })
  },

  /**
   * 修改个人资料
   */
  editMyinfo: function () {
    wx.navigateTo({
      url: './myinfo/myinfo',
    })
  },

  /**
   * 查看我的星星
   */
  myStar: function () {
    wx.navigateTo({
      url: './mystar/mystar',
    })
  },

  /**
   * 查看我的好友
   */
  myfriend: function () {
    wx.navigateTo({
      url: './myfriend/myfriend',
    })
  },


  /**
   * 抓中的商品
   */
  catchedGoods: function () {
    wx.navigateTo({
      url: '../goods/catched_list/catched_list',
    })
  },

  /**
   * 已兑商品
   */
  exchangedGoods: function () {
    wx.navigateTo({
      url: '../goods/exchanged_list/exchanged_list',
    })
  },

  /**
   * 查看订单
   */
  myOrder: function () {
    wx.navigateTo({
      url: './myorder/myorder',
    })
  },

  /**
   * 我的收藏
   */
  mycollection: function () {
    wx.navigateTo({
      url: '../goods/collect_list/collect_list',
    })
  },

  /**
   * 浏览足迹
   */
  readedGoods: function () {
    wx.navigateTo({
      url: '../goods/readed_list/readed_list',
    })
  },

  /**
   * 绑定手机
   */
  bindPhone: function () {
    if (this.data.myinfo.is_bind_mobile == 0) {
      wx.navigateTo({
        url: '../others/register/register',
      })
    }else{
      this.setData({
        message:'已绑定手机',
      })
    }
  },

  /**
   * 新增收货地址
   */
  linktoAddressList: function () {
    wx.navigateTo({
      url: './address/address_list/address_list',
    })
  },

  /**
   * 联系客服
   */
  contactCustomService: function () {
    wx.navigateTo({
      url: '../others/customService/customService',
    })
  }
})